LIBS  = -lfuse -lcurl -lxml2 -lssl -ljson -loauth -losscppcore -lcrypto
TLIBS = ./lib/libsnda_ecs_sdk.a 

LDFLAGS = -Wall 
CPPFLAGS = -Wall -g -D_FILE_OFFSET_BITS=64 -fpermissive
CFLAGS = -Wall -g -D_FILE_OFFSET_BITS=64


PATH = $(GCCDIR):./lib:/usr/bin:/bin
LD = $(GCCDIR)g++
CPP = $(GCCDIR)g++
GCC = $(GCCDIR)gcc
LIBRARY_DIR = -L./lib
INCLUDE_DIR = -I./include -I./include/snda -I./include/osscpp -I/usr/include/libxml2

CPP_FILES := $(wildcard src/*.cpp)
C_FILES := $(wildcard src/*.c)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
OBJC_FILES := $(addprefix objc/,$(notdir $(C_FILES:.c=.o)))

all: obj/moss.o $(OBJ_FILES) $(OBJC_FILES)
	$(LD) $(LD_FLAGS) -o moss $^ $(TLIBS) $(LIBRARY_DIR) $(LIBS)
test: obj/test.o $(OBJ_FILES) $(OBJC_FILES)
	$(LD) $(LD_FLAGS) -o test $^ $(TLIBS) $(LIBRARY_DIR) $(LIBS)

obj/moss.o: moss.cpp
	$(CPP) $(CPPFLAGS) -c moss.cpp -o obj/moss.o $(INCLUDE_DIR)
obj/test.o: test.cpp
	$(CPP) $(CPPFLAGS) -c test.cpp -o obj/test.o $(INCLUDE_DIR)

obj/%.o: src/%.cpp
	$(CPP) $(CPPFLAGS) -c -o $@ $< $(INCLUDE_DIR)

objc/%.o: src/%.c
	$(GCC) $(CFLAGS) -c -o $@ $< $(INCLUDE_DIR)

clean:
	rm -f moss test obj/*.o objc/*.o
